<?php $this->load->view($cfg['tpl__admin'] . 'public/header')?>
<script type="text/javascript" src="<?php echo base_url($cfg['comm'])?>/js/kindeditor/kindeditor-min.js"></script>
<script type="text/javascript" src="<?php echo base_url($cfg['comm'])?>/js/kindeditor/lang/zh_CN.js"></script>
<link rel="stylesheet" href="<?php echo base_url($cfg['comm'])?>/js/kindeditor/themes/default/default.css" />
<script type="text/javascript" language="javascript">
	uploadimage('<?php echo site_url('upload/multiupload/news/'.$cfg['article_thumb_width'].'/'.$cfg['article_thumb_height']);?>','<?php echo base_url();?>',5);
	fulleditor('<?php echo site_url('upload/doUploadImg/news');?>','content');

	function cancel(e)
	{
		$("#"+$(e).attr("rel")).remove();
		$("#cancel"+$(e).attr("rel")).remove();
		$("#sethome"+$(e).attr("rel")).remove();
		$("#hometext"+$(e).attr("rel")).remove();
		$("#br"+$(e).attr("rel")).remove();
		var imgsource = $("#imgsource_"+$(e).attr("rel"));
		var attachpath = $("#attachpath_"+$(e).attr("rel"));
		if (imgsource.length > 0)
		{
			imgsource.remove();
		}
		if (attachpath.length > 0)
		{
			attachpath.remove();
		}
		var k = $(e).attr("rel");
		var _a = $("#attachid"+k);
		if (_a.length > 0)
		{
			var attachid = $("#attachid"+k).val();
			$("#delpic").append('<input type="hidden" name="delimg[]" value="'+attachid+'">');
		}
		
	}

	function sethome(e)
	{
		var imgthumb = $("#pic"+$(e).attr("rel")).val();
		var sourceimage = $("#sourcepic"+$(e).attr("rel")).val();
		$("#homeimage").val(imgthumb);
		$("#homesourceimage").val(sourceimage);
	}

</script>
<div class="so_main">
 
  <form id="form1" name="form1" action="" method="post">		
		<INPUT TYPE="hidden" NAME="articleid" value="<?php echo $row['articleid'];?>">
		<INPUT TYPE="hidden" id="homeimage" NAME="homeimage" value="">
		<INPUT TYPE="hidden" id="homesourceimage" NAME="homesourceimage" value="">
		<div id="delpic">
		</div>
  <div class="form2">
	<dl class="lineD">
      <dt>所属分类：</dt>
      <dd>
         <SELECT NAME="cateid">
			<OPTION VALUE="0" SELECTED>选择分类
			<?php echo $parentcate; ?>
		</SELECT>
    </dl>
    <dl class="lineD">
      <dt>新闻标题：</dt>
      <dd>
        <input name="title" id="title" type="text" value="<?php echo $row['title'];?>"><span>*</span>
    </dl>

	<dl class="lineD">
      <dt>批量图片上传：</dt>
      <dd>
	  <!--<?php $this->load->module("attached/upload/multilimit",array(5,$row['articleid']))?>-->
	  <input type="button" id="J_selectImage" value="批量上传" />
	  <div id="J_imageView" style="margin-tio:10px;">
	  <?php if (!empty($attach)) { $i=1;foreach ($attach as $k => $v) {?>
	  <img id="<?php echo $i?>" src="<?php echo base_url($v['attachpath'])?>" style="margin-right:10px">
	  <input type="radio" name="sethomepage" onclick="sethome(this)" id="sethome<?php echo $i?>" rel="<?php echo $i?>" <?php if ($row['imgthumb'] == $attach[$i-1]['attachpath']){?>checked="checked"<?php }?> ><span id="hometext<?php echo $i?>" style="margin-right:10px">设为主页</span>
	  <input type="button" class="btn_b" id="cancel<?php echo $i?>" onclick="cancel(this)" rel="<?php echo $i?>" value="删除" />
	  <input type="hidden" id="pic<?php echo $i?>" value="<?php echo $v['attachpath']?>">
	  <input type="hidden" id="sourcepic<?php echo $i?>" value="<?php echo $v['attachsourcepath']?>">
	  <input type="hidden" name="oldimg[]" value="<?php echo base_url($v['attachpath'])?>">
	  <input type="hidden" id="attachid<?php echo $i?>" value="<?php echo $v['attachid']?>">
	  <p id="br<?php echo $i?>">&nbsp;</p>
	  <?php $i++;} }?>
	  </div>
	  </dd>
    </dl>
	<dl class="lineD">
      <dt>新闻简介：</dt>
      <dd>
        <textarea name="desc" id="desc" style="width: 600px;"><?php echo  $row['desc']; ?></textarea>
    </dl>
	<dl class="lineD">
      <dt>详细内容：</dt>
      <dd>
        <textarea name="content" id="content" style="width: 600px;"><?php echo set_value('content', $row['content']); ?></textarea>
    </dl>
	<dl class="lineD">
      <dt style="float:left">新闻作者：</dt>
      <dd>
        <input type="text" name="author" value="<?php echo $row['author']?>"/>
    </dl>
	<dl class="lineD">
      <dt style="float:left">新闻来源：</dt>
      <dd>
        <input type="text" name="source" value="<?php echo $row['source']?>"/>
    </dl>
	<dl class="lineD">
      <dt style="float:left">来源链接：</dt>
      <dd>
        <input type="text" name="url" value="<?php echo $row['url']?>"/>
    </dl>
	<!--<dl class="lineD">
	<dt style="float:left">关键字(tag)：</dt>
      <dd>
        <input type="text" name="keywords" value="<?php echo $row['keywords']?>"/>&nbsp;&nbsp;多个关键字用逗号隔开
	</dl>-->
	<dl class="lineD">
      <dt>排序：</dt>
      <dd>
        <input name="sort" id="sort" type="text" value="<?php echo $row['sort'];?>"/>
    </dl>
	<dl class="lineD">
      <dt>是否激活：</dt>
      <dd>
        <label><input name="status" type="radio" value="1" <?php if ($row['status'] == '1') {?> checked <?php } ?>>激活</label>
        <label><input name="status" type="radio" value="0" <?php if ($row['status'] == '0') {?> checked <?php } ?>>未激活</label>
    </dl>
    <div class="page_btm">
      <input type="button" class="btn_b" value="确定" ONCLICK="editArticle()" />&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp<INPUT TYPE="reset" class="btn_b">
    </div>
  </div>
  </form>
</div>
<?php $this->load->view($cfg['tpl__admin'] . 'public/footer')?>



<script type="text/javascript">
function editArticle()
{
	editor.sync();
	postdata('form1', "<?php echo site_url('admin/article' . '/'.$action.'/' . $row['articleid']);?>", 'dd');
}

function dd(d)
{
	if(d.code == '1'){
		$.jBox.tip(d.msg, 'success');
		window.setTimeout(function () {
			window.location.href="<?php echo site_url('admin/article/')?>";
		}, 1000);
	}else{
		$.jBox.tip(d.msg,'error');
	}
}

</script>